package com.banana.manager.forest.controller.handle;

import com.banana.manager.forest.entity.handle.RecordBean;
import com.banana.manager.forest.service.impl.handle.RecordServiceImpl;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDate;

@RestController
@RequestMapping("/record")
public class RecordController {

    @Resource
    private RecordServiceImpl recordService;

    @PostMapping("/addRecord")
    public RecordBean addRecord(@RequestBody RecordBean recordBean){
        return recordService.addRecord(recordBean);
    }

    @GetMapping("/showRecord")
    public RecordBean findOneRecord(Integer recordId){
        return recordService.findById(recordId);
    }

    @GetMapping("/displayRecord")
    public PageInfo<RecordBean> displayRecord(Integer page, String recordName, String recordStage, String recordArea, LocalDate start, LocalDate end){
        System.out.println(
                "测试到达传过来的是什么"+page+recordName+recordStage+start+end
        );
        return recordService.findBlurByPage(page, recordName, recordStage, recordArea, start, end);
    }

    @PostMapping("/updateRecord")
    public RecordBean updateToNewRecord(@RequestBody RecordBean recordBean){
        return recordService.modifyStageAndMeasure(recordBean);
    }

    @GetMapping("/askPhd")
    public RecordBean askPhd(Integer recordId){
        recordService.askPhdHelp(recordId);
        return recordService.findById(recordId);
    }

}
